//
//  XGHomeNavBarView.swift
//  TodayNews
//
//  Created by monkey on 2020/3/1.
//  Copyright © 2020 itcast. All rights reserved.
//

import UIKit

class XGHomeNavBarView: UIView
{
    override init(frame: CGRect)
    {
        super.init(frame: CGRect(x: 0, y: 0, width: TodayNews_Screen_Width, height: 44))
        setUpUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func layoutSubviews()
    {
        super.layoutSubviews()
        
        personButton.frame = CGRect(x: 0, y: 0, width: 44, height: 44)
        searchButton.frame = CGRect(x: personButton.frame.maxX + 10, y: 5, width: bounds.width - personButton.frame.maxX - 20, height: 34)
    }
    
    private lazy var personButton = UIButton(imageName: "home_no_login_head", highlightedImageName: "home_no_login_head", target: nil, action: nil)
    private lazy var searchButton: UIButton = {
        let button = UIButton(title: "请输入搜索内容...", fontSize: 15, normalColor: UIColor.lightGray, imageName: "search_small_16x16_", backgroundColor: UIColor.white, target: nil, action: nil)
        button.imageEdgeInsets = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 0)
        button.titleEdgeInsets = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 0)
        button.contentHorizontalAlignment = .left
        button.layer.cornerRadius = 10
        button.layer.masksToBounds = true
        return button
    }()
    
    private func setUpUI() -> Void
    {
        backgroundColor = UIColor.clear
        addSubview(personButton)
        addSubview(searchButton)
        searchButton.theme_backgroundColor = "colors.cell_background"
    }
}
